import request from '@/utils/request'

const baseURL = '/forum'

// 新增记录
export const savePost = (data) =>
  request.post(`${baseURL}/savePost`, data, {
    headers: {
      'Content-Type': 'multipart/form-data',
    },
  })

// 随机获取记录
export const getPosts = (type, isFavorite) =>
  request.get(`${baseURL}/getPosts`, {
    params: {
      type,
      isFavorite,
    },
  })

// 点赞
export const thumbsUp = (id) =>
  request.get(`${baseURL}/thumbsUp`, {
    params: {
      id,
    },
  })

// 收藏记录
export const favoritePost = (id) =>
  request.get(`${baseURL}/collection`, {
    params: {
      id,
    },
  })

// 获取记录详细信息
export const getDetailPost = (id) =>
  request.get(`${baseURL}/getDetailPost`, {
    params: {
      id,
    },
  })

// 发布评论
export const PostComment = (comment) => request.post(`${baseURL}/PostComment`, comment)

// 获取评论
export const getComments = (id) =>
  request.get(`${baseURL}/getComments`, {
    params: {
      id,
    },
  })

// 点赞评论
export const thumbsUpComment = (id) =>
  request.get(`${baseURL}/thumbsUpComment`, {
    params: {
      id,
    },
  })

// 删除评论
export const deletePostComment = (id) =>
  request.get(`${baseURL}/deletePostComment`, {
    params: {
      id,
    },
  })

// 判断该用户是否点赞评论
export const isUserLikeComment = (id) =>
  request.get(`${baseURL}/isUserLikeComment`, {
    params: {
      id,
    },
  })

// 发布回复
export const replyComment = (data) => request.post(`${baseURL}/replyComment`, data)

// 获取所有回复
export const getSubComments = (id) =>
  request.get(`${baseURL}/getSubComments`, {
    params: {
      id,
    },
  })

// 点赞回复
export const thumbsUpReply = (id) =>
  request.get(`${baseURL}/thumbsUpReply`, {
    params: {
      id,
    },
  })

// 判断当前用户是否喜欢回复
export const isUserLikeReply = (id) =>
  request.get(`${baseURL}/isUserLikeReply`, {
    params: {
      id,
    },
  })

// 判断当前用户是否收藏记录
export const isFavoritePost = (id) =>
  request.get(`${baseURL}/isFavorite`, {
    params: {
      id,
    },
  })

// 删除回复
export const deleteReply = (id) =>
  request.get(`${baseURL}/deleteReply`, {
    params: {
      id,
    },
  })

// 获取当前用户所有记录
export const getCurrentPosts = (page) =>
  request.get(`${baseURL}/getCurrentPosts`, {
    params: {
      page,
    },
  })

// 获取编辑记录
export const getEditPost = (id) =>
  request.get(`${baseURL}/getEditPost`, {
    params: {
      id,
    },
  })

// 更新编辑记录
export const updateEditPost = (data) => request.post(`${baseURL}/updateEditPost`, data)

// 删除帖子
export const deletePost = (id) =>
  request.get(`${baseURL}/deletePost`, {
    params: {
      id,
    },
  })

// 获取历史记录
export const getHistory = () => request.get(`${baseURL}/getHistory`)

// 搜索帖子
export const searchPost = (word) =>
  request.get(`${baseURL}/searchPost`, {
    params: {
      search: word,
    },
  })
